1. Module (chicken continuation)
    1. Continuations API
      1. continuation-capture
      2. continuation?
      3. continuation-graft
      4. continuation-return

Module (chicken continuation)

This module provides a more powerful interface for continuations than that provided by call/cc.

More information about this continuation API can be found in the paper A Better API for First-Class Continuations by Marc Feeley.

Continuations API

continuation-capture

[procedure] (continuation-capture PROCEDURE)

Creates a continuation object representing the current continuation and tail-calls PROCEDURE with this continuation as the single argument.

continuation?

[procedure] (continuation? X)

Returns #t if X is a continuation object, or #f otherwise. Please note that this applies only to continuations created by the Continuation API, but not by call/cc, i.e.: (call-with-current-continuation continuation?) returns #f, whereas (continuation-capture continuation?) returns #t.

continuation-graft

[procedure] (continuation-graft CONT THUNK)

Calls the procedure THUNK with no arguments and the implicit continuation CONT.

continuation-return

[procedure] (continuation-return CONT VALUE ...)

Returns the value(s) to the continuation CONT. continuation-return could be implemented like this:

(define (continuation-return k . vals)
  (continuation-graft
    k
    (lambda () (apply values vals))))

Previous: Module (chicken condition)

Next: Module (chicken csi)